home *** CD-ROM | disk | FTP | other *** search
/ Mission 3 / Mission 3.zip / Mission 3.iso / internet / cabdemo / docs / prog / init.c < prev    next >
C/C++ Source or Header  |  1998-08-29  |  5KB  |  153 lines

  1. /*
  2. ** init.c for Inet-Module
  3. ** Initialisation for HTML.APP browser inet-module
  4. **
  5. ** Copyright (C) 1995, Stephane Boisson. All Rights reserved.
  6. ** Login <boisson@worldnet.net>
  7. **
  8. ** Started on  Sun Aug 27 23:41:30 1995 Stephane Boisson
  9. ** Last update Mon Aug 28 00:44:10 1995 Stephane Boisson
  10. **
  11. ** This file can be redistributed under the terms of the GNU General
  12. ** Public Licence.
  13. */
  14.  
  15. #include <unistd.h>
  16. #include "module.h"
  17.  
  18.  
  19. /*--- Prototypes ---*/
  20. long ___CDECL init_module(url_methods_t *out, browser_info_t *in, char *path);
  21. long ___CDECL get_url_info(char *url, long *timep, long *sizep, char *type);
  22. void ___CDECL get_version(char **authorp, long *versionp, long *datep);
  23. long ___CDECL get_url(char *url, char *filename);
  24. long ___CDECL post(char *url,char *content, char *enctype, char *filename);
  25. void ___CDECL restore_module(void);
  26. long ___CDECL mailto(char *url, char *subject, char *filename);
  27. long ___CDECL get_url_if_modified(char *url, char *filename, long *time);
  28.  
  29. /* new since CAB 2.7 */
  30. long ___CDECL get_url_cookie(char *url, char *filename, char *cookie);
  31. long ___CDECL post_cookie(char *url,char *content, char *enctype, char *filename, char *cookie);
  32. long ___CDECL get_url_ifmod_cookie(char *url, char *filename, long *time, char *cookie);
  33.  
  34. /*--- Global variables ---*/
  35. browser_info_t *browser;
  36.  
  37. /* ----------------------------------------------------------------- **
  38. ** init_module - Initialize the module (called by browser)           **
  39. ** ----------------------------------------------------------------- */
  40. long ___CDECL init_module(out, in, path)
  41. url_methods_t *out;  /* struture to fill */
  42. browser_info_t *in;  /* infos about browser */
  43. char *path;    /* module path, '\' terminated */
  44. {
  45.   /*--- Set browser info variable ---*/
  46.   browser = in;
  47.  
  48.   /*--- Fill URL methods structure ---*/
  49.   out->restore = restore_module;
  50.   out->get_url = get_url;
  51.   out->get_url_info = get_url_info;
  52.   out->get_version = get_version;
  53.   out->mailto = mailto;
  54.   out->post = post;
  55.   out->get_url_if_modified = get_url_if_modified;
  56.  
  57.   /*--- Initialize other stuffs here ---*/
  58.  
  59.   /*--- Return support ---*/
  60.   return(SUPPORT_HTTP|SUPPORT_FTP);
  61. }
  62.  
  63. /* ----------------------------------------------------------------- **
  64. ** mailto - Sends file <filename> as mail to url                     **
  65. ** ----------------------------------------------------------------- */
  66. long ___CDECL mailto(url, subject, filename);
  67. char *url;         /* URL: 'mailto:user@address' */
  68. char *subject;     /* Subject for mail */
  69. char *filename;    /* File */
  70. {
  71.  
  72.   return 0;
  73. }
  74.  
  75.  
  76. /* ----------------------------------------------------------------- **
  77. ** get_version - Returns infos about module                          **
  78. ** ----------------------------------------------------------------- */
  79. void ___CDECL get_version(authorp, versionp, datep)
  80. char **authorp;   /* 4x30 chars separated by '|' */
  81. long *versionp;   /* Version number in BCD format (V1.15 -> 0x00011500) */
  82. long *datep;   /* Date in BCD format (0xYYYYMMDD) */
  83. {
  84.    *versionp = 0x00010000L;
  85.    *datep = 0x19950827L;
  86.    *authorp = "Stephane Boisson|EMAIL: boisson@worldnet.net";
  87. }
  88.  
  89.  
  90. /* ----------------------------------------------------------------- **
  91. ** restore_module - De-initialization                                **
  92. **                  (freeing memory, closing files, etc...)          **
  93. ** ----------------------------------------------------------------- */
  94. void ___CDECL restore_module()
  95. {
  96. }
  97.  
  98.  
  99. /* ----------------------------------------------------------------- **
  100. ** get_url - Fetch URL and write it as a HTML file                   **
  101. **           Returns 0 if OK, else `errno'                           **
  102. ** ----------------------------------------------------------------- */
  103. long ___CDECL get_url(url, filename)
  104. char *url;     /* URL to fetch */
  105. char *filename;      /* file to write to */
  106. {
  107.   return 0;
  108. }
  109.  
  110.  
  111. /* ----------------------------------------------------------------- **
  112. ** post    - Post FORM, fetch result and write it as a HTML file     **
  113. **           Returns 0 if OK, else `errno'                           **
  114. ** ----------------------------------------------------------------- */
  115. long ___CDECL post(url, content, enctype, filename);
  116. char *url;           /* URL to fetch */
  117. char *content;      /* data to post */
  118. char *enctype;      /* format of data */
  119. char *filename;      /* file to write to */
  120. {
  121.   return 0;
  122. }
  123.  
  124.  
  125. /* ----------------------------------------------------------------- **
  126. ** get_url_info - Retreive infos for an URL                          **
  127. **                Returns 0 if OK, else `errno'                      **
  128. ** ----------------------------------------------------------------- */
  129. long ___CDECL get_url_info(url, timep, sizep, type)
  130. char *url;  /* URL */
  131. long *timep;   /* UNIX time */
  132. long *sizep;   /* size of data */
  133. char *type; /* mime type (max len = 250), empty string if unknow */
  134. {
  135.   return 0;
  136. }
  137.  
  138.  
  139. /* ----------------------------------------------------------------- **
  140. ** main - Doesn't useful, but take care that others functions don't  **
  141. **        get `swallowed' by compiler optimizations                  **
  142. ** ----------------------------------------------------------------- */
  143. int main()
  144. {
  145.   static void *array[] = {
  146.     "Needs HTML.APP to run\r\n",
  147.     (void *)BROWSER_MAGIC1, (void *)BROWSER_MAGIC2,
  148.     (void *)BROWSER_MAGIC3, (void *)BROWSER_MAGIC4, init_module};
  149.  
  150.   write(1, array[0], strlen(array[0]));
  151.   return 1;
  152. }
  153.